﻿
Public Class WebCameraInfosPanel

    'Web Camera Infos :
    Private _Infos As ICameraInfos
    Public Property Infos As ICameraInfos
        Get
            Return _Infos
        End Get
        Set(value As ICameraInfos)
            Me.SuspendLayout()
            _Infos = value
            If _Infos IsNot Nothing Then
                If TypeOf _Infos Is JpegCameraInfos OrElse TypeOf _Infos Is MjpegCameraInfos Then
                    KTB_CamName.ReadOnly = False
                    KTB_CamURL.ReadOnly = False
                    KTB_UserName.ReadOnly = False
                    KTB_Password.ReadOnly = False
                    If _Infos.CameraType = CameraType.JpegCamera Then
                        KTB_CamName.Text = CType(_Infos, JpegCameraInfos).CameraName
                        KTB_CamId.Text = CType(_Infos, JpegCameraInfos).CameraId
                        KTB_CamURL.Text = CType(_Infos, JpegCameraInfos).DeviceId
                        KTB_UserName.Text = CType(_Infos, JpegCameraInfos).Login
                        KTB_Password.Text = CType(_Infos, JpegCameraInfos).Password
                    ElseIf _Infos.CameraType = CameraType.MjpegCamera Then
                        KTB_CamName.Text = CType(_Infos, MjpegCameraInfos).CameraName
                        KTB_CamId.Text = CType(_Infos, MjpegCameraInfos).CameraId
                        KTB_CamURL.Text = CType(_Infos, MjpegCameraInfos).DeviceId
                        KTB_UserName.Text = CType(_Infos, MjpegCameraInfos).Login
                        KTB_Password.Text = CType(_Infos, MjpegCameraInfos).Password
                    End If
                Else
                    KTB_CamName.ReadOnly = True
                    KTB_CamURL.ReadOnly = True
                    KTB_UserName.ReadOnly = True
                    KTB_Password.ReadOnly = True
                    KTB_CamName.Text = ""
                    KTB_CamId.Text = ""
                    KTB_CamURL.Text = ""
                    KTB_UserName.Text = ""
                    KTB_Password.Text = ""
                End If
            Else
                KTB_CamName.ReadOnly = True
                KTB_CamURL.ReadOnly = True
                KTB_UserName.ReadOnly = True
                KTB_Password.ReadOnly = True
                KTB_CamName.Text = ""
                KTB_CamId.Text = ""
                KTB_CamURL.Text = ""
                KTB_UserName.Text = ""
                KTB_Password.Text = ""
            End If
            Me.ResumeLayout()
        End Set
    End Property
    'Setting Values :
    Private Sub KTB_CamURL_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles KTB_CamURL.KeyUp
        If _Infos IsNot Nothing Then
            If _Infos.CameraType = CameraType.JpegCamera Then
                CType(_Infos, JpegCameraInfos).SetURL(KTB_CamURL.Text)
            ElseIf _Infos.CameraType = CameraType.MjpegCamera Then
                CType(_Infos, MjpegCameraInfos).SetURL(KTB_CamURL.Text)
            End If
        End If
    End Sub
    Private Sub KTB_CamName_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles KTB_CamName.KeyUp
        If _Infos IsNot Nothing Then
            If _Infos.CameraType = CameraType.JpegCamera Then
                CType(_Infos, JpegCameraInfos).CameraName = KTB_CamName.Text
            ElseIf _Infos.CameraType = CameraType.MjpegCamera Then
                CType(_Infos, MjpegCameraInfos).CameraName = KTB_CamName.Text
            End If
        End If
    End Sub
    Private Sub KTB_UserName_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles KTB_UserName.KeyUp
        If _Infos IsNot Nothing Then
            If _Infos.CameraType = CameraType.JpegCamera Then
                CType(_Infos, JpegCameraInfos).Login = KTB_UserName.Text
            ElseIf _Infos.CameraType = CameraType.MjpegCamera Then
                CType(_Infos, MjpegCameraInfos).Login = KTB_UserName.Text
            End If
        End If
    End Sub
    Private Sub KTB_Password_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles KTB_Password.KeyUp
        If _Infos IsNot Nothing Then
            If _Infos.CameraType = CameraType.JpegCamera Then
                CType(_Infos, JpegCameraInfos).Password = KTB_Password.Text
            ElseIf _Infos.CameraType = CameraType.MjpegCamera Then
                CType(_Infos, MjpegCameraInfos).Password = KTB_Password.Text
            End If
        End If
    End Sub

End Class
